package br.com.devteam.sgap.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;

import br.com.devteam.base.converter.Menuable;
import br.com.devteam.base.util.AlternativasCorretas;

@NamedQueries({
	@NamedQuery(name = Questao.QUERY_LIST_ASC_ORDER,
			query = "select q from Questao q order by pergunta"),
	@NamedQuery(name = Questao.QUERY_SEARCH,
			query = "select q from Questao q where lower(q.pergunta) like lower(:busca)"),
	@NamedQuery(name = Questao.QUERY_PERGUNTA,
			query = "select q from Questao q where q.pergunta = :pergunta"),
})
@Entity
@Table
public class Questao implements Menuable {
	
	public static final String QUERY_LIST_ASC_ORDER = "Questao.listAscOrder";
	public static final String QUERY_SEARCH = "Questao.search";
	public static final String QUERY_PERGUNTA = "Questao.pergunta";

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	@Column
	private Integer id;
	
	@Column(nullable = false)
	private String pergunta;
	
	@Column(nullable = false)
	private String alternativaA;
	
	@Column(nullable = false)
	private String alternativaB;
	
	@Column(nullable = false)
	private String alternativaC;
	
	@Column(nullable = false)
	private String alternativaD;
	
	@ManyToOne(optional = false, fetch = FetchType.EAGER)
	private Tema tema;
	
	@Enumerated(EnumType.STRING)
	private AlternativasCorretas correta;
	
	public Questao() {
	}

	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	public String getPergunta() {
		return pergunta;
	}
	public void setPergunta(String pergunta) {
		this.pergunta = pergunta;
	}
	public String getAlternativaA() {
		return alternativaA;
	}
	public void setAlternativaA(String alternativaA) {
		this.alternativaA = alternativaA;
	}
	public String getAlternativaB() {
		return alternativaB;
	}
	public void setAlternativaB(String alternativaB) {
		this.alternativaB = alternativaB;
	}
	public String getAlternativaC() {
		return alternativaC;
	}
	public void setAlternativaC(String alternativaC) {
		this.alternativaC = alternativaC;
	}
	public String getAlternativaD() {
		return alternativaD;
	}
	public void setAlternativaD(String alternativaD) {
		this.alternativaD = alternativaD;
	}
	public Tema getTema() {
		return tema;
	}
	public void setTema(Tema tema) {
		this.tema = tema;
	}
	/*public RespostaCerta getCerta() {
		return certa;
	}
	public void setCerta(RespostaCerta certa) {
		this.certa = certa;
	}*/
	public AlternativasCorretas getCorreta() {
		return correta;
	}
	public void setCorreta(AlternativasCorretas correta) {
		this.correta = correta;
	}

	@Override
	public Object getIdentifier() {
		return getId() != null ? getId() : -1;
	}

}
